
load.all <- function(inpath, patt, fun) {
  
  list <- list.files(inpath, pattern = patt, recursive = T)
  
  datalist <- lapply(1:length(list), function(i) {
    
  dat <- read.table(paste(inpath, list[i], sep = "/"), header = T, sep = ",", fill = T,
                    stringsAsFactors=F)
  date <- as.character(dat[["Datetime"]])
  index <- list(substr(date, 9, 10))
   
 out <- aggregate(dat, by=index, fun, na.rm=T)
  #print(out)
 out <- out[-1]
 #print(out)
  #names(out) <- names(dat)
  })                                                
write.table(x = datalist, "F:/SpeziellePhysischeGeographie/eimar-vpspph-ws2011/wurst/src/output.txt")
  }

#setwd("D:/SpeziellePhysischeGeographie/Projektarbeit")
#write.table(out, "F:/SpeziellePhysischeGeographie/eimar-vpspph-ws2011/wurst/src/Ergebnis.txt")

## http://r.789695.n4.nabble.com/max-number-from-a-list-of-numbers-td2225172.html